import multiprocessing
import time

def task():
    for i in range(10):
        print("执行任务中,",i)
        time.sleep(0.2)

if __name__ == '__main__':
    sub_process = multiprocessing.Process(target=task)
    sub_process.start()

    time.sleep(0.5)
    print("结束程序")
    # 销毁子进程
    sub_process.terminate()
    exit()
